#define _CRT_SECURE_NO_WARNINGS
#include<vector>
#include<iostream>
using namespace std;
class Solution {
public:
    int minSubArrayLen(int target, vector<int>& nums) {
        int left = 0, right = 0, n = nums.size();
        int sum = nums[right];
        int len = nums.size();
        while (right < n)
        {    
            if (sum < target)
            {
                right++;
                if(right < n) sum += nums[right];
            }
            else
            {
                if (right - left < len) len = right - left + 1;
                sum -= nums[left];
                left++;
            }
        }
        return len;
    }
};
int main()
{
    Solution s1;
    vector<int> v1 = {2,3,1,2,4,3};
    s1.minSubArrayLen(7, v1);
    return 0;
}